package 力扣._8015_距原点最远的点;

public class Solution {
    public int furthestDistanceFromOrigin(String moves) {
        int l = 0, r = 0;
        for (int i = 0; i < moves.length(); i++) {
            if (moves.charAt(i) != 'L')
                r++;
            else
                r--;
            if (moves.charAt(i) != 'R')
                l--;
            else
                l++;
        }
        if (-l > r)
            return -l;
        else
            return r;
    }

    public static void main(String[] args) {
        int i = new Solution().furthestDistanceFromOrigin("L_RL__R");
    }
}
